package com.wanhe.base;

import android.content.Context;
import android.util.Log;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
import com.bumptech.glide.module.GlideModule;

import java.io.File;

/**
 * Created by Administrator on 2017/4/20.
 */

public class InitGlideModule implements GlideModule {
    @Override
    public void applyOptions(Context context, GlideBuilder glideBuilder) {
        Log.d("initGlide","base");
        glideBuilder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
        File storageDirectory = new File(Const.IMG_CACHE);
        int cacheSize = 100*1024*1024;       //设置glide图片目录缓存大小为100M
        glideBuilder.setDiskCache(new DiskLruCacheFactory(storageDirectory.getAbsolutePath(), cacheSize));
//        glideBuilder.setDiskCache(new ExternalCacheDiskCacheFactory(context, Const.imageBaseUrl, DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE));
    }

    @Override
    public void registerComponents(Context context, Glide glide) {

    }
}
